package hr.ctg.service.dao;

import hr.ctg.domain.model.Posta;
import hr.jpa.dao.GenericDAOImpl;

import java.util.List;

import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Name;

@AutoCreate
@Name("postaDAO")
public class PostaDAO extends GenericDAOImpl<Posta, Integer> {

	@SuppressWarnings("unchecked")
	public List<Posta> autocomplete(final Object suggest) {
		final String pref = (String) suggest;
		final List<Posta> poste = entityManager.createNamedQuery(
				"Posta.findAllWithPbr").setParameter(1, pref + "%")
				.getResultList();
		return poste;
	}

	public List<Posta> findAllInZupanija(final int idZupanje) {
		return executeNamedQuery("Posta.findAllInZupanija", idZupanje);
	}
}
